/**
 * 
 */
package sjtu.ist.warehouse4ws.model.file;

import java.util.ArrayList;

import sjtu.ist.warehouse4ws.jcr.RepositoryMoudl;

/**
 * @author ��Ψ��
 *
 */
public class ViewImplement  implements View{
	ArrayList<FileFolder> fileFolders;
	String path;
	String name;
	/**
	 * 
	 */
	public ViewImplement(String path)
	{
		this.path=path;
	}
	public ViewImplement(String name,String path)
	{
		this.path=path;
		this.name=name;
	}
	
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return name;
	}
	
	private void fileFoldersInit(RepositoryMoudl rm)
	{
		fileFolders = new ArrayList<FileFolder>();
		ArrayList<String> names = rm.getNodesNames(path);
		ArrayList<String> paths =rm.getNodesPathes(path);
		for (int i = 0; i < names.size(); i++) {
			fileFolders.add(new FileFolderImp(names.get(i),paths.get(i)));
		}
	}
	public ArrayList<FileFolder> getFileFolders(RepositoryMoudl rm)
	{
		if(fileFolders==null) fileFoldersInit(rm);
		return fileFolders;
	}

}
